var currentImage;

var currentIndex = -1;

var interval;

function showImage(index){

if(index < $('#bigPic-homepage img').length){

var indexImage = $('#bigPic-homepage img')[index]

if(currentImage){

if(currentImage != indexImage ){

$(currentImage).css('z-index',2);

clearTimeout(myTimer);

$(currentImage).fadeOut(250, function() {

myTimer = setTimeout("showNext()", 3000);

$(this).css({'display':'none','z-index':1})

});

}

}

$(indexImage).css({'display':'block', 'opacity':1});

currentImage = indexImage;

currentIndex = index;

$('#thumbs-homepage li').removeClass('active');

$($('#thumbs-homepage li')[index]).addClass('active');

}

}

function showNext(){

var len = $('#bigPic-homepage img').length;

var next = currentIndex < (len-1) ? currentIndex + 1 : 0;

showImage(next);

}

var myTimer;

$(document).ready(function() {

myTimer = setTimeout("showNext()", 3000);

showNext(); //loads first image

$('#thumbs-homepage li a').bind('click',function(e){

var count = $(this).attr('rel');

showImage(parseInt(count)-1);

return false;

});

});

//js for slide

function mycarousel_initCallback(carousel)

{

// Disable autoscrolling if the user clicks the prev or next button.

carousel.buttonNext.bind('click', function() {

carousel.startAuto(0);

});

carousel.buttonPrev.bind('click', function() {

carousel.startAuto(0);

});

// Pause autoscrolling if the user moves with the cursor over the clip.

carousel.clip.hover(function() {

carousel.stopAuto();

}, function() {

carousel.startAuto();

});

};

jQuery(document).ready(function() {

jQuery('#mycarousel').jcarousel({

scroll: 1,

initCallback: mycarousel_initCallback

});

});

jQuery(document).ready(function() {

jQuery('#mycarouse2').jcarousel({

auto: 5,

wrap: 'last',

scroll: 1,

initCallback: mycarousel_initCallback

});

});


$(function() {
    $("img.change")
        .mouseover(function() { 
            var src = $(this).attr("src");
			var post = src.lastIndexOf(".");
			var new_src = src.substring(0,post);
			var new_src = new_src + "-over.jpg";
			$(this).attr("src", new_src);            
        })
        .mouseout(function() {
            var src = $(this).attr("src").replace("-over.jpg", ".jpg");
            $(this).attr("src", src);
        });
});
